
from selenium import webdriver
from selenium.webdriver import ActionChains, Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.select import Select
from selenium.webdriver.support.wait import WebDriverWait

options = webdriver.ChromeOptions()

options.page_load_strategy = "normal"  # 等待页面完全加载
# 创建浏览器驱动对象
driver = webdriver.Chrome(options=options)
# 隐式等待
driver.implicitly_wait(5)
url = r"E:/QQ缓存/A.html"
driver.get(url)

# 定位alerta按钮
driver.find_element(by=By.ID, value="alerta").click()
# 获取警告框
alert = driver.switch_to.alert
# 打印警告框文本
print(alert.text)
# 接受警告框
alert.accept()
# 取消警告框
# alert.dismiss()


input("按任意键关闭")
# # 关闭驱动对象
driver.close()
driver.quit()
print("结束")
